#include "ExpAST.h"
#include "Globe.h"
#include <iostream>
#include "parser.h"
#include "Globe.h"
#pragma warning(disable:4267)
using std::cout;
using std::endl;

unique_ptr<BaseExpAST> parser::parseNumber()
{
    unique_ptr<NumberAST>ret(new NumberAST());
    ret->content = atoi(this->lexer->get_buffer().c_str());
    this->lexer->match(TOK::NUMBER);
    return ret;
}

void NumberAST::Dump() const
{
    cout << "{\"type\":\"Number\",\"content\":" << this->content << "}";
}

bool NumberAST::is_lval() const
{
    return false;
}

void NumberAST::Analyze() const
{
    cmd_code tmp_code;
    tmp_code.op = cmd_code::MOV;
    tmp_code.type1 = cmd_val(cmd_val::INTEGER, 0, this->content);
    tmp_code.type2 = CVR(EAX);
    CurrentFuncMgr->code_list.push_back(tmp_code);;
}